import Vue from "vue";
import Vuex from "vuex";
import state from "./state";
import mutations from "./mutations";
import user from "./modules/user";
import dashboard from "./modules/dashboard";
import { getCookie } from "@/libs/cookie"
Vue.use(Vuex);
const store = new Vuex.Store({
  modules: {
    user,
    dashboard,
  },
  state,
  mutations,

});
export default store;

/**
 * 页面刷新再将local中的token 写入store中
 */

if (getCookie("tjufje")) {
  store.commit("SETSITEID", getCookie("tjufje"))
}

if (getCookie("bqqje")) {
  store.commit("SETAPPID", getCookie("bqqje"))
}
if (getCookie("vtfsjogp")) {
  store.commit("SET_USERINFO", JSON.parse(getCookie("vtfsjogp")))
}